home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{5A65A9C0-089F-11D2-88AD-0000B45C4CF6}#1.2#0"; "EASYX.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 3195
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- Icon = "Form1.frx":0000
- LinkTopic = "Form1"
- ScaleHeight = 3195
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin PROJECTEXLibCtl.EasyX EasyX
- Left = 1200
- OleObjectBlob = "Form1.frx":014A
- Top = 600
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim SpriteArray(15) As Sprite
- Dim SurfaceOne As Long
- Const SpriteWidth As Long = 25
- Const SpriteHeight As Long = 25
- Const MovePrLoop As Long = 10
- Private Sub Form_Load()
- Dim I As Integer, J As Integer, P As Integer
- Dim rt As Long
- Dim AppPath As String
- AppPath = App.Path & "\"
- t forget this
- EasyX.Window = Me.hWnd
- ''''''''''''''''''''''
- 'initialize
- rt = EasyX.InitDirectDraw(640, 480, 8)
- If rt <> EX_OK Then
- MsgBox "Direct draw could not initialize", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'Initialize DInput
- rt = EasyX.InitDirectInput()
- If rt <> EX_OK Then
- MsgBox "Direct input could not initialize", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'Create the keyboard
- rt = EasyX.CreateKeyboard
- If rt <> EX_OK Then
- MsgBox "Direct input could not initialize", vbOKOnly, "Failure"
- Exit Sub
- End If
- EasyX.AcquireKeyboard
- 'create the bitmap surface
- SurfaceOne = EasyX.LoadBitmapFile(AppPath & "balls.bmp", 0)
- If SurfaceOne < 0 Then
- EasyX.EndDirectX
- MsgBox "Could not create bitmap surface", vbOKOnly, "Failure"
- Exit Sub
- End If
- 'create the sprites
- 'Define the sprites of the newly created surface
- For I = 1 To 4
- For J = 1 To 4
- SpriteArray(((I - 1) * 4) + J - 1).Number = EasyX.MakeSprite( _
- (J - 1) * SpriteWidth, _
- (I - 1) * SpriteHeight, _
- J * SpriteWidth, _
- I * SpriteHeight, SurfaceOne)
- Next J
- Next I
- 'randomize the start location and direction of the sprites
- For I = 0 To UBound(SpriteArray)
- SpriteArray(I).PointX = Int((640 - SpriteWidth) * Rnd * 1)
- SpriteArray(I).PointY = Int((480 - SpriteWidth) * Rnd * 1)
- SpriteArray(I).XDirection = 1
- SpriteArray(I).YDirection = -1
- Next I
- 'Everything is set start the timer
- RunMain
- End Sub
- Private Sub RunMain()
- Dim I As Integer
- If EasyX.GetKeyState(EX_ESCAPE) = EX_KEYDOWN Then
- EasyX.EndDirectX
- Unload Me
- Exit Do
- End If
- EasyX.FillSurface 0, EX_PRIMARYSURFACE
- For I = 0 To UBound(SpriteArray)
-
- SpriteArray(I).PointX = SpriteArray(I).PointX + MovePrLoop * SpriteArray(I).XDirection
- SpriteArray(I).PointY = SpriteArray(I).PointY + MovePrLoop * SpriteArray(I).YDirection
-
- If SpriteArray(I).PointX < 0 Then
- SpriteArray(I).PointX = 0
- SpriteArray(I).XDirection = SpriteArray(I).XDirection * -1
- ElseIf (SpriteArray(I).PointX + SpriteWidth) > 640 Then
- SpriteArray(I).PointX = 640 - SpriteWidth
- SpriteArray(I).XDirection = SpriteArray(I).XDirection * -1
- End If
-
- If SpriteArray(I).PointY < 0 Then
- SpriteArray(I).PointY = 0
- SpriteArray(I).YDirection = SpriteArray(I).YDirection * -1
- ElseIf SpriteArray(I).PointY + SpriteHeight > 480 Then
- SpriteArray(I).PointY = 480 - SpriteHeight
- SpriteArray(I).YDirection = SpriteArray(I).YDirection * -1
- End If
-
- EasyX.DrawSprite SpriteArray(I).PointX, SpriteArray(I).PointY, SpriteWidth, SpriteHeight, SpriteArray(I).Number
-
- Next I
- EasyX.FlipSurface
- DoEvents
-
- End Sub
-